package com.zhl.common.service;

import com.zhl.common.anno.IoAnno;
import com.zhl.common.domain.AbstractUpFileRQ;
import com.zhl.common.domain.TencentUpFileRq;
import com.zhl.common.enums.IoEnum;
import com.zhl.common.utils.COSUtils;

/**
 * @description 腾讯云文件处理实现
 * @Author: z156940l@outlook.com
 * @className TencentFileService
 * @Date: 2024/7/21 14:23
 */
@IoAnno(type = IoEnum.TENCENT_CLOUD)
public class TencentFileService extends AbstractFileService {

    private final COSUtils cosUtils;

    public TencentFileService(COSUtils cosUtils) {
        this.cosUtils = cosUtils;
    }

    @Override
    public String upFile(AbstractUpFileRQ abstractUpFileRQ) {
        TencentUpFileRq rq = (TencentUpFileRq) abstractUpFileRQ;
        return cosUtils.uploadInputStream(rq.getBas64(), rq.getName());
    }

    @Override
    public String showUrl(String key) {
        return cosUtils.showObj(key);
    }
}
